

{include file="pageheader.htm"}

<script src="js/utils.js" ></script>
<script src="js/listtable.js" ></script>

<form method="post" action="?page=orderstatus&action=save" name="listForm" onsubmit="return confirmSubmit(this)">

<!-- 订单状态 -->

<div class="list-div" id="listDiv">
	
	<table border="0" cellspacing="5" cellpadding="5" id="tbl_orderstatus">
		<tr><th>订单状态id</th>
			<th>状态(jpn)</th>
			<th>状态(en)</th>
			<th>状态(por)</th>
			<th>删除?</th>
		</tr>
	
		
		{foreach item="ods" from=$orderstatus}
		<tr>
			<td><input type="text" name="status_id[{$ods.id}]" value="{$ods.id}" id="status_id[{$ods.id}]" style="width:50px" ></td>
			<td><input type="text" name="status_jpn[{$ods.id}]" value="{$ods.jpn}" id="status_jpn[{$ods.id}]"></td>
			<td><input type="text" name="status_en[{$ods.id}]" value="{$ods.en}" id="status_en[{$ods.id}]"></td>
			<td><input type="text" name="status_por[{$ods.id}]" value="{$ods.por}" id="status_por[{$ods.id}]"></td>
			<td><a href="?page=orderstatus&action=drop&id={$ods.id}" >[-]</a></td>
		</tr>
		{/foreach}
	</table>
  
	<br>
	<table border="0" cellspacing="5" cellpadding="5">		
		<tr><td align="center">
			<input type="button" name="additem" value="新状态" id="additem" onclick="addnewstatus();" >
			&nbsp;&nbsp;<input type="submit" name="submit" value="保存" id="submit">
			
		</td></tr>
	</table>
</div>

</form>

{literal}

<script type="text/javascript" charset="utf-8">
	
	function findMaxItemid(dom){
		if (!dom) return 0;
		if (dom.rows.length <= 1) return 0;
		
		re = /^status_id\[(.*)]$/;
		max = 0;
		
		for(i = 1; i <= (dom.rows.length -1); i++){
			name = dom.rows[ dom.rows.length - 1 ].cells[0].childNodes[0].name;						
			ret = name.match(re);
			if (ret){
				currentid = eval(ret[1]);
				if ( currentid > max ){
					max = currentid;			
					}			
				}
			}
		return max;
		}
		
		
	function droprow(row){
		table = document.getElementById('tbl_orderstatus');
		
		if(!table) return;
		if(table.rows.length < row ) return;
		
		table.deleteRow(row+1);		
		}
	
	
	
	function createinput(id, name){
		e = document.createElement('input');
		e.type = "text";
		e.name = name + '[' + id + ']';
		e.id = e.name;		
		return e;	
		}
			
	
	function addnewstatus(){		
		
		table = document.getElementById('tbl_orderstatus');
		
		
		if (table){
			
			i = findMaxItemid(table) + 1;
			newline = document.createElement('tr');			
			newitem1 = document.createElement('td');
			
			input = createinput(i, 'status_id');			
			input.style.width = '50px';
			input.value = i;
			newitem1.appendChild(input);
			
			newitem2 = document.createElement('td');
			input = createinput(i, 'status_jpn');
			newitem2.appendChild(input);
			
			newitem3 = document.createElement('td');
			input = createinput(i, 'status_en');
			newitem3.appendChild(input);
			
			newitem4 = document.createElement('td');
			input = createinput(i, 'status_por');
			newitem4.appendChild(input);
			
			delitem = document.createElement('td');
			delitem.innerHTML = '<input type="button" onclick="droprow('+ i +');" value="[-]" >';
					
			newline.appendChild(newitem1);
			newline.appendChild(newitem2);
			newline.appendChild(newitem3);
			newline.appendChild(newitem4);
			newline.appendChild(delitem);
				
			table.tBodies[0].appendChild(newline);			
			}
		}
		
		
	
</script>

{/literal}



{include file="pagefooter.htm"}
